#include <iostream>

class Base {
public:
    int baseValue;

    Base(int value) : baseValue(value) {}

    virtual void print() {
        std::cout << "Base class: " << baseValue << std::endl;
    }
};

class Derived : public Base {
public:
    int derivedValue;

    Derived(int base, int derived) : Base(base), derivedValue(derived) {}

    void print() override {
        std::cout << "Derived class: " << baseValue << ", " << derivedValue << std::endl;
    }
};

int main() {
    Derived derivedObj(10, 20);
    Base baseObj = derivedObj;  // 对象切片发生在此处

    baseObj.print();  // 调用的是 Base::print()

    Base* test = new Derived(10,20);
    test->print();

    return 0;
}
